package com.ibm.spatiotemp.server.framework.processor.dynamodb;

import java.sql.SQLException;

import org.apache.log4j.Logger;

import com.ibm.spatiotemp.server.connections.ConnectionManager;
import com.ibm.spatiotemp.server.connections.DynamodbConnection;
import com.ibm.spatiotemp.server.datamodel.gpsdata.TSPointResultSet;
import com.ibm.spatiotemp.server.datasources.DataSource;
import com.ibm.spatiotemp.server.framework.processor.RawDataProcessor;
import com.ibm.spatiotemp.server.framework.request.Request;

public class DynamodbRawDataProcessor extends RawDataProcessor{
	
	public static Logger logger = Logger.getLogger(DynamodbRawDataProcessor.class);
	
	private DynamodbProcessor innerprocessor;
	public DynamodbRawDataProcessor(DataSource src) {
		super(src);
		try {
			DynamodbConnection conn = 
					(DynamodbConnection) 
					ConnectionManager.GetConnection(src.getConnection_string());
			conn.setRelatedsrc(src);
			innerprocessor = new DynamodbProcessor(conn);
		} catch (SQLException e) {
			logger.error(e);
		}
	}

	@Override
	public TSPointResultSet handleRawDataQuery(Request request)
			throws Exception {
		return innerprocessor.handleRawDataQuery(request);
	}

	@Override
	public String handleRawDataInsert(Request request) throws Exception {
		return innerprocessor.handleinsertTimeSeriesData(request);
	}

}
